import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import LoginView from '@/views/LoginView.vue'
import Layout from '@/views/Layout.vue'
import ProductListView from '@/views/productListView.vue'
import ProductAddView from '@/views/productAddView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: Layout,
      // 路由重定向
      redirect:'/home',
      children:[
        {
          path: '/home',
          name: 'home',
          component: HomeView,
        },
        {
          path: '/prolist',
          name: 'prolist',
          component: ProductListView,
        },
        {
          path: '/proadd',
          name: 'proadd',
          component: ProductAddView,
        },
      ]
    },
    {
      path: '/login',
      name: 'login',
      
      component: LoginView,
    },
  ],
})

export default router
